import unittest
from word import *
from document import *

class TestDocument(unittest.TestCase):
    def setUp(self):
        self.document_1 = document("C:/project", "document1", ".html")
        self.document_2 = document("C:/project", "document1", ".html")
        self.document_3 = document("C:/ebook", "document3", ".html")
  
    def testEqual(self):
        self.assertEqual(self.document_1.__eq__(self.document_2), True)
        self.assertEqual(self.document_2.__eq__(self.document_3), False)
    
    def testGetFileName(self):
        x = self.document_1.getFileName()
        self.assertEqual(x, "document1.html")
        x = self.document_3.getFileName()
        self.assertEqual(x, "document3.html")
    
    def testAddWord(self):
        self.document_1.addWord("nice", 3)
        self.document_1.addWord("job", 6)
        self.document_1.addWord("job", 100)
        self.assertEqual(self.document_1.word_objects["job"].locations, [6,100])
        
if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDocument)
    unittest.TextTestRunner(verbosity=2).run(suite)